package com.sptpc.drink.service.impl;

import com.sptpc.drink.dao.CategoryMapper;
import com.sptpc.drink.pojo.Category;
import com.sptpc.drink.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public Category queryById(Long id) {
        return categoryMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Category> queryAll() {
        return categoryMapper.selectAllCategory();
    }

    @Override
    public List<Category> queryByName(String name) {
        return categoryMapper.selectCategoryByName(name);
    }

    @Override
    public void insert(Category category) {
        categoryMapper.insertSelective(category);

    }

    @Override
    public void delete(Long id) {
        categoryMapper.deleteByPrimaryKey(id);

    }

    @Override
    public void update(Category category) {
        categoryMapper.updateByPrimaryKeySelective(category);

    }
}
